/*
初始化时使用fields先生成redner序列 
再循环data处理数据

*/
import FieldsType from 'field/type'
export default {
  format(fields = []) {
    // 数据渲染队列
    var rednerList = {}
    for (let field of fields) {
      if (FieldsType[field.type] && FieldsType[field.type].render) {
        rednerList[field.code] = (row) => {
          return FieldsType[field.type].render(row[field.code])
        }
      }
    }
    return (row) => {
      var item = {}
      for (let code in rednerList) {
        item[code] = rednerList[code](row)
      }
      return item
    }
  }
}
